package com.snopy.concurrency.atomic;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Supplier;

/**
 * @author snopy
 * @version 1.0.0
 * @classname AtomicArray
 * @description
 * @email 77912204@qq.com
 * @date 2022/06/28 14:16
 */
public class AtomicArray {
    public static void main(String[] args) {

    }

    private static <T> void demo(Supplier<T> adderSupplier, Consumer<T> action){
        T adder = adderSupplier.get();
        long starter = System.nanoTime();
        List<Thread> ts = new ArrayList<>();
        //4个线程，每人累加50万
        for (int i = 0; i < 40; i++) {
            ts.add(new Thread(()->{
                for (int j = 0; j < 50000; j++) {
                    action.accept(adder);
                }
            }));
        }
    }
}
